/**
* Created by wust on 2020/4/9.
*/
<template>
  <div id="work-order-timeline">
    <el-timeline>
      <el-timeline-item :timestamp="data.timestamp" placement="top" v-for="(data, index) in timelineData" :key="index" color="#0bbd87">
        <el-card>
          <p>{{data.description}}</p>
        </el-card>
      </el-timeline-item>
    </el-timeline>
  </div>
</template>
<script>
import Vue from 'vue'

export default {
  name: 'work-order-timeline',
  props: ['selectedModel'],
  data () {
    return {
      formModel: {},
      timelineData: {}
    }
  },
  created: function () {
    this.formModel = this.selectedModel
    this.timelineDetail()
  },
  methods: {
    timelineDetail: function () {
      Vue.$ajax({
        method: 'post',
        url: Vue.$workOrderServerURL + '/web/v1/WorkOrderTimelineController/timelineDetail?workOrderNumber=' + this.formModel.workOrderNumber
      }).then(res => {
        if (res.data.flag !== 'SUCCESS') {
          if (!Vue.$isNullOrIsBlankOrIsUndefined(res.data.message)) {
            this.$message({
              message: res.data.message,
              type: 'warning'
            })
          }
        } else {
          this.timelineData = res.data.obj
        }
      })
    }
  }
}
</script>
